﻿@using CHILIS.Componentes.CoreRestaurant.Model.Adquicisiones;
@{
    List<AD_Insumo> insumo = (List<AD_Insumo>)ViewBag.ListadoInsumos;
    Dictionary<int, int> detalleInsumo = new Dictionary<int, int>();// = (Dictionary<int, int>)ViewBag.listadoDetalleInsumo;    



    detalleInsumo = (Dictionary<int, int>)ViewBag.listadoDetalleInsumo;
    if (Session["listaInsumo"] == null)
    {
        Session["listaInsumo"] = detalleInsumo;
    }
    int NroSol = -1;
    if (ViewBag.NumeroSolicitud != null)
    {
        NroSol = (int)ViewBag.NumeroSolicitud;
    }
    

}
<script language="javascript" type="text/javascript">
    $('#tbListaMantSolicitudInsumo').dataTable();
</script>
<div class="container">
    <table id="tbListaMantSolicitudInsumo" class="offset1 table-bordered">
        <thead>
            <tr>
                <th>
                    C&oacute;digo
                </th>
                <th>
                    Descripci&oacute;n
                </th>
                <th>
                    Cantidad
                </th>
                <th>
                </th>
                <th>
                </th>
            </tr>
        </thead>
        <tbody>
            @if (detalleInsumo != null)
            {
                foreach (KeyValuePair<int, int> item in detalleInsumo)
                {
                <tr>
                    <td class="span1">
                        @item.Key
                    </td>
                    <td class="span3">
                        @{
                    var firstOrDefault = insumo.FirstOrDefault(x => x.Codigo_Insumo == item.Key);
                        }
                        @if (firstOrDefault != null)
                        {
                            @firstOrDefault.Descripcion_Insumo
                        }
                    </td>
                    <td class="span1">
                        @item.Value
                    </td>
                    <td>
                        <a href="#" class="editarDetalleSolicitudInsumo icon-edit" data-numerosolicitud="@NroSol" data-codigoinsumo="@item.Key" data-cantidad="@item.Value" >
                        </a>Editar
                    </td> 
                    <td>
                        <a href="#" class="eliminarDetalleSolicitudInsumo icon-remove" data-numerosolicitud="@NroSol" data-codigoinsumo="@item.Key">
                        </a>Eliminar
                    </td>
                </tr>
                }
            }
        </tbody>
        <tfoot>
            <tr>
                <th>
                </th>
                <th>
                </th>
                <th>
                </th>
                <th>
                </th>
                <th>
                </th>
            </tr>
        </tfoot>
    </table>
</div>
